package demo1;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-08-09
 * Time: 9:38
 */
public class TestDemo2 {
    //Scanner写法
    public static void main(String[] args) {
        try(InputStream inputStream = new FileInputStream("text.txt")){
            Scanner scanner = new Scanner(inputStream);
            while(scanner.hasNext()){
                System.out.println(scanner.next());
            }
        }catch(IOException e){
            e.printStackTrace();
        }
    }
}
